#!/usr/bin/perl
use File::Spec;

my $root=shift;
my $pf_from=shift;
my $pf_to=shift;
(defined($root) && defined($pf_from) && defined($pf_to)) || die("Bad command line arguements");
$root=File::Spec->rel2abs($root);
my $mv="mv";

chdir $root;
opendir DIR,$root;

foreach my $sub (readdir(DIR)) {
    if($sub=~/\.$pf_from/){
        my $to=$sub;
        $to=~s/\.$pf_from/\.$pf_to/g;
        my $cmd="$mv $sub $to";
        print "$cmd\n";
        system("$cmd");
    }
}

close DIR;
